package com.dkts.oil.util;


import lombok.extern.slf4j.Slf4j;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * 公共的数据解析
 *
 * @author heguanglong
 * @date 2022/3/23
 */
@Slf4j
public class CommWriterFileInfo {


    public static BufferedWriter getWriterBuffer(String url, boolean addFile) {
        try {
            return new BufferedWriter(new FileWriter(url, addFile));
        } catch (IOException e) {
            log.error("写入错误：url:{}", url, e);
        }
        return null;
    }

    public static void writer(BufferedWriter writer, String data) {
        try {
            writer.write(data + "\n");
            writer.flush();
        } catch (IOException e) {
            log.error("写入错误：", e);
        }
    }


}
